﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="ScrollBarThumbStyle"
           TargetType="{x:Type Thumb}">
        <Setter Property="Focusable"
                Value="False"></Setter>
        <Setter Property="IsTabStop"
                Value="False"></Setter>
        <Setter Property="Background"
                Value="{DynamicResource QslNormalBackgroundBrush}"></Setter>
        <Setter Property="BorderBrush"
                Value="{DynamicResource QslNormalBorderBrush}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Rectangle Name="Border"
                               StrokeThickness="1"
                               Stroke="{DynamicResource QslNormalBorderBrush}"
                               Fill="{DynamicResource QslNormalBackgroundBrush}"></Rectangle>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDragging"
                                 Value="True">
                            <Setter TargetName="Border"
                                    Property="Fill"
                                    Value="{DynamicResource QslPressedBackgroundBrush}"></Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ScrollBarLineButtonStyle"
           TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable"
                Value="False"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid>
                        <Rectangle Name="Border"
                                   StrokeThickness="1"
                                   Stroke="{DynamicResource QslNormalBorderBrush}"
                                   Fill="{DynamicResource QslNormalBackgroundBrush}"></Rectangle>
                        <ContentPresenter HorizontalAlignment="Center"
                                          VerticalAlignment="Center"></ContentPresenter>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="Border"
                                    Property="Fill"
                                    Value="{DynamicResource QslPressedBackgroundBrush}"></Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ScrollBarPageButtonStyle"
           TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable"
                Value="False"></Setter>
        <Setter Property="IsTabStop"
                Value="False"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="FlatVerticalScrollBar"
                     TargetType="{x:Type ScrollBar}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition MaxHeight="30" />
                <RowDefinition Height="*" />
                <RowDefinition MaxHeight="30" />
            </Grid.RowDefinitions>
            <RepeatButton Grid.Row="0"
                          Height="30"
                          Style="{StaticResource ScrollBarLineButtonStyle}"
                          Command="ScrollBar.LineUpCommand">
                <Path Fill="{DynamicResource QslNormalGlyphBrush}"
                      Data="M 0 4 L 8 4 L 4 0 Z"></Path>
            </RepeatButton>
            <Track Name="PART_Track"
                   Grid.Row="1"
                   IsDirectionReversed="True">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageUpCommand"
                                  Style="{StaticResource ScrollBarPageButtonStyle}"></RepeatButton>
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Margin="0"
                           Style="{StaticResource ScrollBarThumbStyle}"></Thumb>
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageDownCommand"
                                  Style="{StaticResource ScrollBarPageButtonStyle}"></RepeatButton>
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton Grid.Row="2"
                          Height="30"
                          Style="{StaticResource ScrollBarLineButtonStyle}"
                          Command="ScrollBar.LineDownCommand">
                <Path Fill="{DynamicResource QslNormalGlyphBrush}"
                      Data="M 0 0 L 4 4 L 8 0 Z"></Path>
            </RepeatButton>
        </Grid>
    </ControlTemplate>
    <ControlTemplate x:Key="FlatHorizontalScrollBar"
                     TargetType="{x:Type ScrollBar}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="30" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition MaxWidth="30" />
            </Grid.ColumnDefinitions>
            <RepeatButton Grid.Row="0"
                          Width="30"
                          Style="{StaticResource ScrollBarLineButtonStyle}"
                          Command="ScrollBar.LineLeftCommand">
                <Path Fill="{DynamicResource QslNormalGlyphBrush}"
                      Data="M 4 0 L 4 8 L 0 4 Z"></Path>
            </RepeatButton>
            <Track Name="PART_Track"
                   Grid.Column="1"
                   IsDirectionReversed="False">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageLeftCommand"
                                  Style="{StaticResource ScrollBarPageButtonStyle}"></RepeatButton>
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Margin="0"
                           Style="{StaticResource ScrollBarThumbStyle}"></Thumb>
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageRightCommand"
                                  Style="{StaticResource ScrollBarPageButtonStyle}"></RepeatButton>
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton Grid.Column="2"
                          Width="30"
                          Style="{StaticResource ScrollBarLineButtonStyle}"
                          Command="ScrollBar.LineRightCommand">
                <Path Fill="{DynamicResource QslNormalGlyphBrush}"
                      Data="M 0 0 L 0 8 L 4 4 Z"></Path>
            </RepeatButton>
        </Grid>
    </ControlTemplate>

    <Style TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="OverridesDefaultStyle"
                Value="True" />
        <Style.Triggers>
            <Trigger Property="Orientation"
                     Value="Vertical">
                <Setter Property="Width"
                        Value="35" />
                <Setter Property="Height"
                        Value="Auto" />
                <Setter Property="Margin"
                        Value="0,-2,-2,-2" />
                <Setter Property="Template"
                        Value="{DynamicResource FlatVerticalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation"
                     Value="Horizontal">
                <Setter Property="Width"
                        Value="Auto" />
                <Setter Property="Height"
                        Value="35" />
                <Setter Property="Margin"
                        Value="-1,-1,-1,-1" />
                <Setter Property="Template"
                        Value="{DynamicResource FlatHorizontalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>